package com.itm.lqm.servlets.teacher;

import java.io.IOException;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.itm.lqm.entity.Teacher;
import com.itm.lqm.service.TeacherService;


/**
 * Servlet implementation class updateStudent1
 */
@WebServlet("/updateTeacher1")
public class updateTeacher1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public updateTeacher1() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取修改页面的请求参数，然后调用业务逻辑层对象，实现最终修改
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");

		int tid =Integer.parseInt(request.getParameter("tid"));
		System.out.println(tid);
		String tno =request.getParameter("tno");
		String tname =request.getParameter("tname");
		String role = request.getParameter("role");
		String sex = request.getParameter("sex");
	
		
		
		Teacher t= new Teacher(tid,tno, tname,role,sex);
		TeacherService ts=new TeacherService();
		boolean result=ts.updateTeacher(t);
		System.out.println(t);
		System.out.println(result);
		if(result){
			request.getRequestDispatcher("findAllTeacher").forward(request, response);
		}else{
			response.sendRedirect("updateTeacher.jsp");
		}
		
	}

	

}
